package com.gitee.elf.core.data

import com.google.gson.*
import java.lang.reflect.Type

class DataString(var value: String) : Data {

    override fun getValue(): Any {
        return value
    }

    override fun toString(): String {
        return value
    }

    override fun clone(): DataString {
        return DataString(value)
    }

    @SerializerType(DataString::class)
    class Serializer : JsonSerializer<DataString>, JsonDeserializer<DataString> {
        override fun serialize(src: DataString?, typeOfSrc: Type?, context: JsonSerializationContext?): JsonElement {
            return JsonPrimitive(src!!.value)
        }

        override fun deserialize(json: JsonElement?, typeOfT: Type?, context: JsonDeserializationContext?): DataString {
            return DataString(json!!.asString)
        }


    }
}